package com.wc.alorithm_luogu.P5738;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/24 10:51
 * @description
 * https://www.luogu.com.cn/problem/P5738
 * 歌唱比赛
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int curMin = 10;
        int curMax = 0;
        int curSum = 0;
        int curScore = 0;
        double maxAvgScore = 0;

        int n = sc.nextInt();
        int m = sc.nextInt();
        int tmp;
        while (n-- > 0) {
            tmp = m;
            curMax = 0;
            curMin = 10;
            curSum = 0;

            while (tmp-- > 0) {
                curScore = sc.nextInt();
                curSum += curScore;
                curMax = Math.max(curMax, curScore);
                curMin = Math.min(curScore, curMin);
            }
            maxAvgScore = Math.max((curSum - curMin - curMax) * 1.0 / (m - 2), maxAvgScore);
        }
        System.out.printf("%.2f", maxAvgScore);

    }
}
